import 'package:flutter/material.dart';

class GridViewWidgetPageState extends StatefulWidget {
  @override
  _GridViewWidgetPageStateState createState() =>
      new _GridViewWidgetPageStateState();
}

class _GridViewWidgetPageStateState extends State<GridViewWidgetPageState> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('GridViewWidgetPageState'),
      ),
      body: GridView.builder(
        itemCount: 50,
          shrinkWrap: true,
          physics: ClampingScrollPhysics(),
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            mainAxisSpacing: 10,
            crossAxisSpacing: 5,
            childAspectRatio: 1.2
          ),
          itemBuilder: (BuildContext ctx, int index) {
            return Container(
              child: Padding(
                padding: EdgeInsets.all(15),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Image.asset(
                      "./images/landscape.jpg",
                      width: double.infinity,
                      height: 80,
                    ),
                    SizedBox(height: 5),
                    Text('你好',style: TextStyle(fontSize: 18),)
                  ],
                ),
              ),
            );
          }),
    );
  }
}
